import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  // state专门用来保存 共享的状态值
  state: {
    // 保存登录状态
    login: false,
    customerId: '',
    power1: ''
  },
  // mutations: 专门书写方法,用来更新 state 中的值
  mutations: {
    // 登录
    doLogin(state,{id,power}) {
      state.login = true;
      state.customerId=id;
      state.power1=power;
    },
    // 退出
    doLogout(state) {
      state.login = false;
      state.customerId='';
      state.power1='';
    }
  }
});

export default store
